package com.itheima.test;

import com.itheima.dao.UserDao;
import com.itheima.daomain.User;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;
import java.util.List;

public class test {
    public static void main(String[] args) throws Exception{
        InputStream in= Resources.getResourceAsStream("config.xml");
        SqlSessionFactoryBuilder builder=new SqlSessionFactoryBuilder();
        SqlSessionFactory build = builder.build(in);
        SqlSession session = build.openSession();
        UserDao dao = session.getMapper(UserDao.class);
        List<User> users = dao.findAll();
        for (User user : users) {
            System.out.println(user);
        }
        session.close();
        in.close();
    }
}
